Skip to content

Support incremental_strategy parameter and new insert_overwrite strategy#2195

Open
SuchodolskiEdvin wants to merge 2 commits into
mainfrom
insert_overwrite_incremental_strategy
Open

Support incremental_strategy parameter and new insert_overwrite strategy#2195
SuchodolskiEdvin wants to merge 2 commits into
mainfrom
insert_overwrite_incremental_strategy

Conversation

@SuchodolskiEdvin

Copy link
Copy Markdown
Collaborator
  • updated proto with new parameters
  • added new tests
  • added validation for chosen incremental_strategies
  • added new insert_overwrite strategy logic

@SuchodolskiEdvin SuchodolskiEdvin requested a review from a team as a code owner June 2, 2026 14:39
@SuchodolskiEdvin SuchodolskiEdvin requested review from zaptot and removed request for a team June 2, 2026 14:39
@SuchodolskiEdvin SuchodolskiEdvin force-pushed the insert_overwrite_incremental_strategy branch from 9f72a8c to 9724071 Compare June 2, 2026 15:13
@SuchodolskiEdvin SuchodolskiEdvin requested review from kolina and removed request for zaptot June 3, 2026 09:56
@SuchodolskiEdvin SuchodolskiEdvin force-pushed the insert_overwrite_incremental_strategy branch from 9724071 to 41d152d Compare June 3, 2026 13:46
Comment thread cli/api/dbadapters/execution_sql.ts
Comment thread cli/api/dbadapters/execution_sql.ts Outdated
MERGE ${resolveTargetTable} T
USING \`${stagingTableUnqualified}\` S
ON FALSE
WHEN NOT MATCHED BY SOURCE AND ${partitionBy} IN UNNEST(partitions_for_replacement) ${updatePartitionFilter ? `and T.${updatePartitionFilter}` : ""} THEN

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such code T.${updatePartitionFilter} will only work when updatePartitionFilter has exactly one expression?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are correct. It is a known limitation that T.${updatePartitionFilter} only works for simple expressions (and fails on multi-expression SQL). Current implementation is designed to match the existing behavior of the standard MERGE strategy to maintain consistency between the two strategies for now. The fix of using updatePartitionFilter with several expression will be introduced in a separate PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to implement it correctly from the start. IIRC current behaviour for MERGE may require an opt-in flag to avoid breaking existing code, so I'd avoid such compatibility issues.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Comment thread cli/api/dbadapters/execution_sql.ts Outdated
Comment thread core/actions/incremental_table.ts Outdated
Comment thread core/actions/incremental_table_test.ts Outdated
Comment thread protos/configs.proto Outdated
@SuchodolskiEdvin SuchodolskiEdvin force-pushed the insert_overwrite_incremental_strategy branch 4 times, most recently from f11f8f3 to 1942a72 Compare June 8, 2026 16:29
Comment thread core/actions/incremental_table_test.ts
Comment thread core/actions/incremental_table_test.ts
Comment thread core/actions/incremental_table.ts Outdated
case dataform.IncrementalStrategy.INSERT_OVERWRITE:
if (!this.proto.bigquery || !this.proto.bigquery.partitionBy) {
this.session.compileError(
new Error("incrementalStrategy 'insert_overwrite' requires 'partitionBy' to be set."),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Inconsistent style. in some places we have capital first letter and in others we don't. We also use "." in some places and miss it in others. for example on line 759.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Comment thread cli/api/dbadapters/execution_sql.ts
Comment thread cli/api/dbadapters/execution_sql.ts
Comment thread cli/api/dbadapters/execution_sql.ts
Comment thread cli/api/goldens/insert_overwrite_ignore.sql
...baseTable,
incrementalStrategy: dataform.IncrementalStrategy.INSERT_OVERWRITE,
bigquery: {
partitionBy: "DATE(ts)",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have an example column that is not a function like Date. My concern is that we a re biased toward handling this method. so it its just a normal column name we might not handle it correctly.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added additional test for normal column.

@SuchodolskiEdvin SuchodolskiEdvin force-pushed the insert_overwrite_incremental_strategy branch 3 times, most recently from a90b434 to 8f1bcb7 Compare June 22, 2026 16:03
@SuchodolskiEdvin SuchodolskiEdvin requested a review from Tuseeq1 June 22, 2026 16:30
Comment thread cli/api/dbadapters/execution_sql.ts
Comment thread cli/api/dbadapters/execution_sql.ts Outdated
MERGE ${resolveTargetTable} T
USING \`${stagingTableUnqualified}\` S
ON FALSE
WHEN NOT MATCHED BY SOURCE AND ${partitionBy} IN UNNEST(partitions_for_replacement) ${updatePartitionFilter ? `and T.${updatePartitionFilter}` : ""} THEN

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to implement it correctly from the start. IIRC current behaviour for MERGE may require an opt-in flag to avoid breaking existing code, so I'd avoid such compatibility issues.

- updated proto with new parameters
- added new tests
- added validation for chosen incremental_strategies
- added new insert_overwrite strategy logic
@SuchodolskiEdvin SuchodolskiEdvin force-pushed the insert_overwrite_incremental_strategy branch 2 times, most recently from d5b89f1 to eb6ca9b Compare July 3, 2026 08:37
- Replaced legacy 'T' and 'S' MERGE aliases with explicit 'DATAFORM_DEST' and 'DATAFORM_SOURCE' in the BigQuery adapter.
- Updated `incremental_table_test.ts` assertions.
- Documented the new `incrementalPredicates` property in the OSS API reference.
@SuchodolskiEdvin SuchodolskiEdvin force-pushed the insert_overwrite_incremental_strategy branch from eb6ca9b to cc9eb94 Compare July 3, 2026 09:01
@SuchodolskiEdvin SuchodolskiEdvin requested a review from kolina July 3, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants